from django.db import models

# 创建投诉类，包括类别、姓名、通信地址、联系电话、标题、是否愿意公开、电子邮件、通信邮编、qq号码、投诉内容、附件
class Complaint(models.Model):
    complaint_type = models.CharField(choices=(('1', '投诉'), ('2', '咨询'), ('3', '建议'), ('4', '感谢')), max_length=1, verbose_name='投诉类别')
    name = models.CharField(max_length=10, verbose_name='姓名')
    address = models.CharField(max_length=100, verbose_name='通信地址',null=True,blank=True)
    phone = models.CharField(max_length=11, verbose_name='联系电话')
    title = models.CharField(max_length=100, verbose_name='标题')
    is_public = models.BooleanField(default=False, verbose_name='是否愿意公开')
    email = models.EmailField(max_length=100, verbose_name='电子邮件',null=True,blank=True)
    post_code = models.CharField(max_length=10, verbose_name='通信邮编',null=True,blank=True)
    qq = models.CharField(max_length=20, verbose_name='qq号码',null=True,blank=True)
    content = models.TextField(verbose_name='投诉内容')
    attachment = models.FileField(upload_to='complaints', verbose_name='附件',null=True,blank=True)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = '投诉'
        verbose_name_plural = verbose_name
